<?php
class SP_Database_Relation
{

	private $name;
	private $type;
	private $local_key;
	private $foreign_key;
	private $foreign_class;
	private $ref_class;
	private $delete_method='none';
	private $update_method='none';
	
	public function __construct($attr=null)
	{
		if(is_array($attr))
		{
			foreach($attr as $key => $value)
			{
				$this->$key=$value;
			}
		}
	}
	
	public function setName($value)
	{
		$this->name=$value;
		return $this;
	}
	
	public function setType($value)
	{
		$this->type=$value;
		return $this;
	}
	
	public function setTypeMany()
	{
		$this->type='many';
		return $this;
	}
	
	public function setTypeOne()
	{
		$this->type='one';
		return $this;
	}
	
	public function setLocalKey($value)
	{
		$this->local_key=$value;
		return $this;
	}
	
	public function setForeignKey($value)
	{
		$this->foreign_key=$value;
		return $this;
	}
	
	public function setForeignClass($value)
	{
		$this->foreign_class=$value;
		return $this;
	}
	
	public function setRefClass($value)
	{
		$this->ref_class=$value;
		return $this;
	}
	
	public function setDeleteCascade()
	{
		$this->delete_method='cascade';
		return $this;
	}
	
	public function setDeleteNone()
	{
		$this->delete_method='none';
		return $this;
	}
	
	public function setDeleteOnlyRefs()
	{
		$this->delete_method='only_refs';
		return $this;
	}
	
	public function setUpdateCascade()
	{
		$this->update_method='cascade';
		return $this;
	}
	
	public function setUpdateNone()
	{
		$this->update_method='none';
		return $this;
	}
	
	public function setUpdateOnlyRefs()
	{
		$this->update_method='only_refs';
		return $this;
	}
	
	public function getName()
	{
		return $this->name;
	}
	
	public function getType()
	{
		return $this->type;
	}
	
	public function getLocalKey()
	{
		return $this->local_key;
	}
	
	public function getForeignKey()
	{
		return $this->foreign_key;
		
	}
	
	public function getForeignClass()
	{
		return $this->foreign_class;
	}
	
	public function getRefClass()
	{
		return $this->ref_class;
	}
	
	public function getDeleteMethod()
	{
		return $this->delete_method;
	}
	
	public function getUpdateMethod()
	{
		return $this->update_method;
	}
	
	
}